﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using WCSY.BLL;
using WCSY.MODEL;

public partial class ReportManagement_costExecutSumReport : System.Web.UI.Page
{
    Fg_deptInfoManager deptM = new Fg_deptInfoManager();
    protected void Page_Load(object sender, EventArgs e)
    {
        if(!IsPostBack){
            //绑定预算部门
            DataTable deptList = deptM.GetAllList().Tables[0];
            this.ddlDept.DataSource = deptList;
            this.ddlDept.DataTextField = "deptname";
            this.ddlDept.DataValueField = "deptno";
            this.ddlDept.DataBind();
            //绑定费用项
            fg_costsManager costsm = new fg_costsManager();
            this.ddlCosts.DataSource = costsm.GetAllList();
            this.ddlCosts.DataTextField = "name";
            this.ddlCosts.DataValueField = "code";
            this.ddlCosts.DataBind();
            //绑定期间
            this.ddlperiod.Items.Add("第一期");
            this.ddlperiod.Items.Add("第二期");
            this.ddlperiod.Items.Add("第三期");
            this.ddlperiod.Items.Add("第四期");
            this.ddlperiod.Items.Add("第五期");
            this.ddlperiod.Items.Add("第六期");
            this.ddlperiod.Items.Add("第七期");
            this.ddlperiod.Items.Add("第八期");
            this.ddlperiod.Items.Add("第九期");
            this.ddlperiod.Items.Add("第十期");
            this.ddlperiod.Items.Add("第十一期");
            this.ddlperiod.Items.Add("第十二期");
            wcsy_costsOrderMstManager mstm = new wcsy_costsOrderMstManager();
            gvBind(mstm.getBuActioveSumReport("-1","-1","","-1"));
           
        }
    }

    public void gvBind(DataTable gvdt) {
        this.GridView1.DataSource = gvdt;
        this.GridView1.DataBind();
    }
    /// <summary>
    /// 查询数据
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnSec_Click(object sender, EventArgs e)
    {
        
        string uyear = txtUyear.Text;
        string period = ddlperiod.SelectedValue;

        if (!period.Equals("-1"))
        {
            period =  ddlperiod.SelectedItem.Text ;
        }
        wcsy_costsOrderMstManager mstm = new wcsy_costsOrderMstManager();
        gvBind(mstm.getBuActioveSumReport(ddlDept.SelectedValue,ddlCosts.SelectedValue, uyear, period));
    }
    //双击绑定行
    protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            string busysNo = e.Row.Cells[1].Text.ToString();// 获取预算编码
            string deptno = e.Row.Cells[4].Text.ToString();// 获取部门编码
            string costsno = e.Row.Cells[6].Text.ToString();// 获取费用项编码

            e.Row.Attributes.Add("ondblclick", "toDetail('"+busysNo+"','"+deptno+"','"+costsno+"')");

        }
    }
}
